package com.leantech.android.browser.ui

import com.leantech.android.browser.dialog.PrivacyDialog
import com.leantech.android.browser.ui.browser.BrowserActivity
import com.cscj.android.utils.LOG
import com.lean.android.ad.core.PrivacyDialogBlockChain
import com.lean.android.ad.core.config.ChannelInfoProvider
import com.lean.android.ad.core.splash.SplashAdLauncherActivity
import org.koin.android.ext.android.inject
import splitties.activities.start

class SplashActivity : SplashAdLauncherActivity() {

    private lateinit var privacyDialog: PrivacyDialog

    private val channelInfoProvider by inject<ChannelInfoProvider>()

    override fun showPrivacyDialog(chain: PrivacyDialogBlockChain) {
        LOG.d("show privacy dialog.")
        if (!::privacyDialog.isInitialized) {
            privacyDialog = PrivacyDialog(this, channelInfoProvider.getChannel() == "003", {
                chain.onAccept {}
            }, {
                chain.onDenied()
            })
        }

        privacyDialog.show()
    }

    override fun launchMain() {
        start<BrowserActivity>()
    }

}